import {
  Component,
  OnInit
} from '@angular/core';
import {
  FollowListService
} from './follow-list.service';

@Component({
  selector: 'app-follow-list',
  templateUrl: './follow-list.component.html',
  styleUrls: ['./follow-list.component.css']
})
export class FollowListComponent implements OnInit {
  dataSet = [];

  isVisible = false;
  constructor(
    private followListService: FollowListService
  ) { }

  ngOnInit() {
    this.followListService.getList().subscribe(res => {
      console.log(res);
      this.dataSet = res;
    });
  }
  getLjzf(item) {
    var initPrice = item.init_price;
    var dwjz = item.dwjz;
    if (item.multiplier) {
      dwjz = dwjz * item.multiplier;
    }
    var ljzf = ((dwjz / initPrice - 1) * 100).toFixed(2);
    return ljzf + '%';
  }
  getGsLjzf(item) {
    var initPrice = item.init_price;
    var gsz = item.gsz;
    if (item.multiplier) {
      gsz = gsz * item.multiplier;
    }
    var ljzf = ((gsz / initPrice - 1) * 100).toFixed(2);
    return ljzf + '%';
  }
  getNum(price: number) {
    return (10 / price).toFixed(2);
  }
  showModal(): void {
    this.isVisible = true;
  }

  handleOk(): void {
    console.log('Button ok clicked!');
    this.isVisible = false;
  }

  handleCancel(): void {
    console.log('Button cancel clicked!');
    this.isVisible = false;
  }
}
